<template>
<div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="修改密码" name="first">修改密码</el-tab-pane>
        <el-tab-pane label="个人资料" name="second">个人资料</el-tab-pane>
        <el-tab-pane label="上传头像" name="third">上传头像</el-tab-pane>
        <el-tab-pane label="收货管理" name="fourth">收货管理</el-tab-pane>
    </el-tabs>
</div>
</template>

<script>
export default {
    name:'XiaoEl-Main-Tabs',
    data(){
        return{
            // activeName2:'1-2',
            activeName2:'',
            activeName:'',
            // activeName: 'second',   //默认打开el-tabs的第几个
        }
    },
    methods:{
        handleClick(tab, event) {
            // console.log(tab, event);
            if(tab.index == 0){
                this.activeName2='1-1';
                this.$router.push({name:'xchangepsw'})
            }else if(tab.index == 1){
                this.activeName2='1-2';
                this.$router.push({name:'xperdata'})
            }else if(tab.index == 2){
                this.activeName2='1-3';
                this.$router.push({name:'xuploadavatar'})
            }else if(tab.index == 3){
                this.activeName2='1-4';
                this.$router.push({name:'xrecmanage'})
            }
        },
    },
    watch:{
        activeName2(val){
            this.$bus.$emit('ELMainTabstoLeftAside',val)
        }
    },
    mounted(){
        this.$bus.$on('LeftAsidetoELMainTabs',(val)=>{
            this.activeName=val
        })
    },
    beforeDestroy(){
        this.$bus.$off('LeftAsidetoELMainTabs')
    },
}
</script>

<style>

</style>